package com.service.admin.borrow.controller;

import com.service.admin.borrow.controller.rep.MemberBorrowPageRep;
import com.service.admin.borrow.controller.req.MemberBorrowPageReq;
import com.service.admin.borrow.service.MemberBorrowService;
import com.service.admin.framework.log.RequestLog;
import com.service.core.rest.BaseController;
import com.service.core.rest.response.BaseResponse;
import com.service.core.rest.response.PageResponse;
import com.service.utility.common.UUIDUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController()
@Api(tags = "用户借贷")
@RequestMapping("member-borrow")
public class MemberBorrowController extends BaseController {

    @Autowired
    private MemberBorrowService memberBorrowService;
    /**
     * 分页条件查询用户借贷记录列表
     * @param req
     * @return
     */
    @ApiOperation("分页查询用户借贷列表")
    @RequestLog("分页查询用户借贷列表")
    @PostMapping("page-list")
    public PageResponse<MemberBorrowPageRep> pageList(@ApiParam @RequestBody MemberBorrowPageReq req){
        String uuid = UUIDUtil.randomUUID();
        log.info("请求开始 Msg: 请求参数：{}，UUID:{}", req, uuid);
        log.info("请求结束： UUID:{}", uuid);
        return successQueryPageResponse(memberBorrowService.listPageByParams(req));
    }
    @ApiOperation("查询用户借贷详情")
    @RequestLog("查询用户借贷详情")
    @PostMapping("details")
    public BaseResponse details(@ApiParam Integer id){
        return successQueryOneResponse(memberBorrowService.details(id));
    }
}
